<?php


    // Author: Tomasz Durka
    // Date: 4th April 2007
    // Prints out a HTML submit tag
    
    
  function submit ($value, array $params = array()) {
    
    $style = '';
    $id = '';
    $name = '';
    $generic = '';
    $confirm = '';
    $on_click = '';
    $disabled = '';
    $class = ' class="submit"';
    
    foreach ($params as $_name => $_value) {
      switch ($_name) {
        case 'style':
        case 'id':
        case 'name':
          $generic .= " {$_name}=\"{$_value}\"";
        break;
        case 'class':
          $class = " {$_name}=\"{$_value} submit\"";
        break;
        case 'confirm':
          $confirm = "if (!confirm('{$_value}')) return false;";
        break;
        case 'on_click':
          $on_click = "{$_value}";
        break;
        case 'disabled':
          if ($_value == true) {
            $disabled = " disabled=\"disabled\"";
          }
        break;
      }
    }
    
    $returned = "<input type=\"submit\" value=\"{$value}\"{$class}{$generic}{$disabled} onClick=\"{$confirm}{$on_click}\" />";
    return $returned;
  }

?>